package com.chinasofti.myjdk8datetime;

import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;

public class JDK8DateDemo8 {
    public static void main(String[] args) throws ParseException {
        LocalDate localDate1 = LocalDate.of(2020,1,1);
        LocalDate localDate2 = LocalDate.of(2040,12,12);
        Period period = Period.between(localDate1,localDate2);
        System.out.println("period = " + period); //P20Y11M11D
        System.out.println(period.getYears());//期间的年数
        System.out.println(period.getMonths());//期间的月数
        System.out.println(period.getDays());//期间的天数

        System.out.println(period.toTotalMonths());//期间的总月数

    }
}
